// 分类
export const categoriesData = () => {
  const data = [
    { name: '前端', code: 'frontend', sort: 1 },
    { name: '后端', code: 'backend', sort: 2 },
    { name: '数据库', code: 'database', sort: 3 },
    { name: '安全', code:'security', sort: 4 },
    { name: '设计', code: 'design', sort: 5 },
    { name: '产品', code: 'product', sort: 6 },
    { name: '数据结构与算法', code: 'algorithms', sort: 7 },
    { name: '机器学习', code: 'machineLearning', sort: 8 },
    { name: '设计模式', code: 'designPatterns', sort: 9 },
    { name: '计算机基础', code: 'computerFundamentals', sort: 10 },
  ]

  const navData = data.map(item => {
    const { name, code } = item
    return {
      text: name,
      link: `/content/categories/${code}/intro`,
      activeMatch: `/content/categories/${code}`
    }
  })

  return { navData }
}

// 百宝箱
export const treasureData = () => {
  const data = [
    { name: '好用的工具', code: 'usefulTools', sort: 1 },
    { name: '宝藏资源', code: 'resources', sort: 2 },
    { name: '网站导航', code: 'websiteNavigation', sort: 3 },
    { name: '摸鱼', code:'slackOff', sort: 4 },
    { name: '插件市场', code: 'extensions', sort: 5 },
  ]

  return getNavData(data, 'treasure')
}

// 百宝箱
export const aboutData = () => {
  const data = [
    { name: '个人信息', code: 'personInfo', sort: 1 },
    { name: '工作经历', code: 'workExperience', sort: 2 },
  ]

  return getNavData(data, 'about')
}

const getNavData = (data, category) => {
  return data.map(item => {
    const { name, code } = item
    return {
      text: name,
      link: `/content/${category}/${code}`,
      activeMatch: `/content/${category}/${code}`
    }
  })
}